<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 商品总览
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">

            <el-table :data="tableData.list" border class="table" ref="multipleTable" header-cell-class-name="table-header">


                <el-table-column prop="gid" label="商品编号" width="90" align="center"></el-table-column>


                <el-table-column prop="gname" label="商品名"></el-table-column>


                <el-table-column prop="gcategory" label="商品类别"></el-table-column>
                    

                <el-table-column prop="gmodel" label="商品规格"></el-table-column>


                <el-table-column prop="gprice" label="商品价格"></el-table-column>


                <el-table-column prop="gnumber" label="商品总库存"></el-table-column>
                
                <el-table-column label="商品图片" align="center">
                    <template #default="scope">
                        <el-image class="table-td-thumb" :src="scope.row.gthumb" :preview-src-list="[scope.row.gthumb]">
                        </el-image>
                    </template>
                </el-table-column>
                
                



                </el-table>

            <div class="pagination">
              <el-pagination background layout="total, prev, pager, next" :current-page="tableData.currentPage"
                  :page-size="tableData.rows" :total="tableData.totalCount" @current-change="handlePageChange"></el-pagination>
          </div>
           
        </div>

    </div>
</template>

<script>
import { ref, reactive,onMounted } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import axios from "axios";

export default {
    name: "basetable",
       setup(){
        let tableData=ref({
            currentPage:1,
            rows:6,
            list: [],
            totalCount:0,
            totalPage:0

        })




        const query=ref({
            currentPage:1,
            rows:6,
        })

        

        axios({
            method:'POST',
            url:'/api/goodsQueryServlet',
            data:query.value

        }).then(function(resp){
            tableData.value=resp.data.data
            console.log(query.value)
            console.log(resp.data.data)
            localStorage.setItem("ms_list",resp.data.data.list)
            console.log(resp.data.data.list)
        })

        const handlePageChange = (val) => {
        tableData.currentPage=val;
          axios({
              method: 'post',
              url: '/api/goodsQueryServlet',
              data:
              {
                  currentPage: val,
                  rows:6,
              }
          }).then(function (resp) {
              tableData.value = resp.data.data
          });
      }


        return{
            tableData,
            query,
            handlePageChange,
        }

       }  
       
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
